
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电商用户消费倾向预测模型仪表板</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        
        .header {
            text-align: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            border-radius: 10px;
            margin-bottom: 30px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        
        .header h1 {
            margin: 0;
            font-size: 2.5em;
        }
        
        .header p {
            margin: 10px 0 0 0;
            font-size: 1.2em;
            opacity: 0.9;
        }
        
        .controls {
            background: white;
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 30px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .controls h3 {
            margin-top: 0;
            color: #333;
        }
        
        .button-group {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 15px;
        }
        
        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
            background: #667eea;
            color: white;
        }
        
        .btn:hover {
            background: #5a67d8;
            transform: translateY(-2px);
        }
        
        .btn.active {
            background: #48bb78;
        }
        
        .visualization-container {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        .visualization {
            text-align: center;
            display: none;
        }
        
        .visualization.active {
            display: block;
        }
        
        .visualization img {
            max-width: 100%;
            height: auto;
            border-radius: 5px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .visualization h3 {
            color: #333;
            margin-bottom: 20px;
            font-size: 1.5em;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        
        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .stat-card h4 {
            margin: 0 0 10px 0;
            color: #667eea;
            font-size: 1.1em;
        }
        
        .stat-card .value {
            font-size: 2em;
            font-weight: bold;
            color: #333;
        }
        
        .footer {
            text-align: center;
            margin-top: 40px;
            padding: 20px;
            color: #666;
        }
        
        @media (max-width: 768px) {
            .button-group {
                flex-direction: column;
            }
            
            .btn {
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>🛒 电商用户消费倾向预测仪表板</h1>
        <p>基于多源数据的用户消费模式分析与预测</p>
    </div>
    
    <!-- 统计卡片 -->
    <div class="stats-grid">
        <div class="stat-card">
            <h4>最佳模型</h4>
            <div class="value">LR</div>
        </div>
        <div class="stat-card">
            <h4>最高准确率</h4>
            <div class="value">0.933</div>
        </div>
        <div class="stat-card">
            <h4>训练模型数量</h4>
            <div class="value">8</div>
        </div>
        <div class="stat-card">
            <h4>用户样本数</h4>
            <div class="value">1000</div>
        </div>
    </div>
    
    <!-- 控制面板 -->
    <div class="controls">
        <h3>📊 选择可视化类型</h3>
        <div class="button-group">
            <button class="btn active" onclick="showVisualization('model_performance')">
                📈 模型性能对比
            </button>
            <button class="btn" onclick="showVisualization('confusion_matrix')">
                🎯 混淆矩阵
            </button>
            <button class="btn" onclick="showVisualization('data_distribution')">
                📊 数据分布
            </button>
            <button class="btn" onclick="showVisualization('feature_importance')">
                🔍 特征重要性
            </button>
            <button class="btn" onclick="showVisualization('training_time')">
                ⏱️ 训练时间
            </button>
        </div>
    </div>
    
    <!-- 可视化容器 -->
    <div class="visualization-container">
        <div id="model_performance" class="visualization active">
            <h3>📈 模型性能对比</h3>
            <img src="" alt="模型性能对比">
            <p style="color: #666; margin-top: 15px;">
                展示了所有训练模型在准确率、精确率、召回率和F1分数上的表现对比
            </p>
        </div>
        
        <div id="confusion_matrix" class="visualization">
            <h3>🎯 混淆矩阵 - Basic LR</h3>
            <img src="" alt="混淆矩阵">
            <p style="color: #666; margin-top: 15px;">
                显示最佳模型在各消费倾向类别上的预测准确性，对角线值越高表示该类别预测越准确
            </p>
        </div>
        
        <div id="data_distribution" class="visualization">
            <h3>📊 数据分布分析</h3>
            <img src="" alt="数据分布">
            <p style="color: #666; margin-top: 15px;">
                展示了用户年龄、收入、消费倾向等级和总消费的分布情况
            </p>
        </div>
        
        <div id="feature_importance" class="visualization">
            <h3>🔍 特征重要性分析</h3>
            <img src="" alt="特征重要性">
            <p style="color: #666; margin-top: 15px;">
                基于TF-IDF分析的最重要特征，显示对预测结果影响最大的文本特征
            </p>
        </div>
        
        <div id="training_time" class="visualization">
            <h3>⏱️ 模型训练时间对比</h3>
            <img src="" alt="训练时间">
            <p style="color: #666; margin-top: 15px;">
                比较不同模型的训练时间，帮助在准确性和效率之间做出权衡
            </p>
        </div>
    </div>
    
    <!-- 模型性能表格 -->
    <div class="visualization-container">
        <h3>📋 详细性能指标</h3>
        <div style="overflow-x: auto;">
            <table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
                <thead>
                    <tr style="background-color: #f8f9fa;">
                        <th style="padding: 12px; border: 1px solid #ddd; text-align: left;">模型</th>
                        <th style="padding: 12px; border: 1px solid #ddd; text-align: center;">测试准确率</th>
                        <th style="padding: 12px; border: 1px solid #ddd; text-align: center;">精确率</th>
                        <th style="padding: 12px; border: 1px solid #ddd; text-align: center;">召回率</th>
                        <th style="padding: 12px; border: 1px solid #ddd; text-align: center;">F1分数</th>
                    </tr>
                </thead>
                <tbody>

                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Multinomial NB</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.6867</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.6660</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.6867</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.6761</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Gaussian NB</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.2800</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.7688</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.2800</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.3875</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Complement NB</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.7200</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.7447</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.7200</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.7206</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Basic LR</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9327</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Optimized LR</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9338</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9326</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Linear SVM</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9337</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9322</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">RBF SVM</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.8333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.8329</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.8333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.8272</td>
                    </tr>
    
                    <tr>
                        <td style="padding: 12px; border: 1px solid #ddd; font-weight: bold;">Optimized SVM</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9337</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9333</td>
                        <td style="padding: 12px; border: 1px solid #ddd; text-align: center;">0.9331</td>
                    </tr>
    
                </tbody>
            </table>
        </div>
    </div>
    
    <div class="footer">
        <p>🚀 电商用户消费倾向预测模型训练完成 | 多源数据融合、特征工程、模型训练与评估</p>
        <p style="font-size: 0.9em; margin-top: 10px;">
            基于用户基础信息、交易记录、浏览行为等数据，预测用户消费倾向等级
        </p>
    </div>
    
    <script>
        function showVisualization(vizId) {
            // 隐藏所有可视化
            const visualizations = document.querySelectorAll('.visualization');
            visualizations.forEach(viz => {
                viz.classList.remove('active');
            });
            
            // 显示选中的可视化
            document.getElementById(vizId).classList.add('active');
            
            // 更新按钮状态
            const buttons = document.querySelectorAll('.btn');
            buttons.forEach(btn => {
                btn.classList.remove('active');
            });
            
            // 设置当前按钮为活跃状态
            event.target.classList.add('active');
        }
        
        // 页面加载完成后的动画效果
        window.addEventListener('load', function() {
            const cards = document.querySelectorAll('.stat-card');
            cards.forEach((card, index) => {
                setTimeout(() => {
                    card.style.opacity = '0';
                    card.style.transform = 'translateY(20px)';
                    card.style.transition = 'all 0.5s ease';
                    
                    setTimeout(() => {
                        card.style.opacity = '1';
                        card.style.transform = 'translateY(0)';
                    }, 100);
                }, index * 150);
            });
        });
    </script>
</body>
</html>
